package config.service.impl;

import com.github.pagehelper.PageHelper;
import com.util.BeanUtil;
import com.util.PagedResult;
import config.mapper.MailConfigMapper;
import config.mapper.SmsConfigMapper;
import config.model.MailConfig;
import config.model.SmsConfig;
import config.service.ConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;


/**
 * Created by shugen on 2017/2/28.
 */
@Service
public class ConfigServiceImpl implements ConfigService {
    @Autowired
    MailConfigMapper mailConfigMapper;
    @Autowired
    SmsConfigMapper smsConfigMapper;


    public PagedResult<MailConfig> selectMail(Map map) {
        PageHelper.startPage((Integer) map.get("page"),(Integer)map.get("rows"));  //分页参数
        return BeanUtil.toPagedResult(mailConfigMapper.select());
    }

    public int updateMail(MailConfig record) {
        return mailConfigMapper.update(record);
    }


    public PagedResult<SmsConfig> selectSms(Map map) {
        PageHelper.startPage((Integer) map.get("page"),(Integer)map.get("rows"));  //分页参数
        return BeanUtil.toPagedResult(smsConfigMapper.select());
    }


    public int updateSms(SmsConfig record) {
        return smsConfigMapper.update(record);
    }
}
